package com.ww.sound_emission.controller;

import com.ww.sound_emission.domain.Favorites;
import com.ww.sound_emission.service.FavoritesService;
import com.ww.sound_emission.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/favorites")
public class FavoriteController {

    @Autowired
    private FavoritesService favoriteService;

    // 添加收藏
    @PostMapping
    public Result<String> addFavorite(@RequestBody Favorites favorite) {
        favoriteService.save(favorite);
        return Result.success("收藏成功");
    }

    // 取消收藏
    @DeleteMapping("/{id}")
    public Result<String> deleteFavorite(@PathVariable Long id) {
        favoriteService.removeById(id);
        return Result.success("取消收藏成功");
    }
}